package com.terren.spider.core.html.util;

import java.util.Properties;

import com.terren.spider.core.html.configuration.strategy.ProxyBlackListStrategy;
import com.terren.spider.core.html.configuration.strategy.ProxyWhiteListStrategy;
import com.terren.spider.entity.config.SysConfig;
import com.terren.spider.util.common.CommonUtil;

public class ProxyDomainStrategyUtil {
	private static ProxyWhiteListStrategy abuyunWhiteListProxy;
	private static ProxyBlackListStrategy abuyunBlackListProxy;
	
	
	/**
	 * abuyun白名单策略
	 * @return
	 */
	public static ProxyWhiteListStrategy getAbuyunWhiteListProxy() {
		if (null==abuyunWhiteListProxy) {
	        Properties properties = CommonUtil.getSysConfigProperties();
	        abuyunWhiteListProxy = new ProxyWhiteListStrategy();
            String whiteListProperty = properties.getProperty(SysConfig.ABUYUN_WHITE_LIST_STRATEGY);
            if (null!=whiteListProperty) {
            	abuyunWhiteListProxy.addAllHost(whiteListProperty);
			}
		}
		return abuyunWhiteListProxy;
	}
	
	/**
	 * abuyun黑名单策略
	 * @return
	 */
	public static ProxyBlackListStrategy getAbuyunBlackListProxy() {
		if (null==abuyunBlackListProxy) {
	        Properties properties = CommonUtil.getSysConfigProperties();
	        abuyunBlackListProxy = new ProxyBlackListStrategy();
            String blackListProperty = properties.getProperty(SysConfig.ABUYUN_BLACK_LIST_STRATEGY);
            if (null!=blackListProperty) {
            	abuyunBlackListProxy.addAllHost(blackListProperty);
			}
		}
		return abuyunBlackListProxy;
	}
	
}
